package com.huonan.service.orderservice.controller;

import com.huonan.service.orderservice.domain.Order;
import com.huonan.service.orderservice.service.IOrderService;
import com.huonan.service.orderservice.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author huonan
 * @date 2020/2/27 16:12
 * @desc
 */
@RestController
public class HelloOrderService {

    @RequestMapping("/hello")
    public String index() {
        return "Hello World-HelloOrderService";
    }

    @Autowired
    private OrderService orderService;

    @Autowired
    private IOrderService iorderService;

    @GetMapping("/order/{id}")
    public Order queryOrderById(@PathVariable("id") String id) {
        return orderService.queryOrderById(id);
    }

    @GetMapping("/forder/{id}")
    public ResponseEntity queryOrderById2(@PathVariable("id") String id) {
        return ResponseEntity.ok(iorderService.queryItemById(Integer.valueOf(id)));
    }
}
